using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;

namespace eTMS.WindowServices
{
    partial class WRLC : ServiceBase
    {
        public WRLC()
        {
            InitializeComponent();
        }
        static WRLC serviceController;
        //public static void Main()
        //{
        //    try
        //    {
        //        serviceController = new WRLC();
        //        ServiceBase.Run(serviceController);
        //    }
        //    catch (Exception ex)
        //    {
        //        File.WriteAllText(Application.StartupPath + "\\error.txt", ex.ToString());
        //    }
        //}
        [STAThread]
        public static void Main()
        {
            serviceController = new WRLC();
            serviceController.OnStart(null);
            Application.Run(new Form());

        }

        ServiceEntry server;

        protected override void OnStart(string[] args)
        {

            try
            {
                server = new ServiceEntry();
                server.StartServices();
            }
            catch (Exception ex)
            {
                File.WriteAllText(Application.StartupPath + "\\error.txt", ex.ToString());
            }
        }


        protected override void OnStop()
        {
            server.CloseServices();
        }
    }
}
